#ifndef __COMPONENT_ON_FIRE_H__
#define __COMPONENT_ON_FIRE_H__

#include "Component.hpp"

namespace PocketSurvival
{

    struct ComponentBody;

    struct ComponentOnFire : public Component
    {
        entt::entity attacker = entt::null;
        float fireDuration = 0.0f;
        double nextCheckTime;
        ComponentBody* componentBody;
        uint32_t fireTouchCount = 0;
        bool touchesFire;

        void setOnFile(entt::entity attackerEntity, float duration);
        inline void extinguish();

        virtual void update(float dt) override;
        virtual const std::string &getName() const override;
        static const std::string &GetName();
        virtual void load(const nlohmann::json &jsonData) override;
        virtual void save(nlohmann::json &jsonData) override;
        virtual void saveToMsgJson(nlohmann::json &jsonData) override;
    };
    
    inline void ComponentOnFire::extinguish()
    {
        attacker = entt::null;
        fireDuration = 0.0f;
    }

} // namespace PocketSurvival

#endif
